const App = getApp()
Page({
  data: {
    check: false,
    oil: '',
    pageShow:false,
    info:['','',''],
  },
  onLoad: function (options) {
    let that = this
    that.oil()
  },
  onReady: function () {

  },
  oil() {
    let that = this
    let address=wx.getStorageSync('address')
    App.api.$http({
      url: 'user/rules',
      method: 'Post',
      data: {
      }
    }, {}).then(res => {
      that.setData({
        pageShow:true,
        ...res.data
      })
    })

  },
  bindRegionChange(e){
    this.setData({
      info: e.detail.value
    })
  },
  // 提交锁价申请
  sure(e) {
    let that = this
    var flag = that.data.flag
    if (flag) {
      return
    }
    that.setData({
      flag: true
    })
    if (!that.data.check) {
      App.api.$showSuccess('请阅读并勾选协议')
      that.setData({
        flag: false
      })
      return
    }
    var objData = e.detail.value;
    for (const key in objData) {
      if (!objData[key]) {
        wx.showToast({
          title: '请完善申请信息',
          icon:"none"
        })
        that.setData({
          flag: false
        })
        return;
      }
    }
    App.api.$http({
      url: 'user/stationApply',
      method: 'Post',
      data: objData
    }, {}).then(res => {
      if(res){
        App.api.$showSuccess(res.msg)
        setTimeout(function(){
          wx.navigateBack()
        },2000)
      }
    })
  },
  onShow: function () {

  },
  checkcon() {
    let that = this
    that.setData({
      check: !that.data.check
    })
  },
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

})